<?php
require_once("lib/db_connection.php");
$queue_id = $_GET['queue_id'];
$queue_id = base64_decode($queue_id);
$query_queue = "SELECT * FROM queue_tbl WHERE autoid='".$queue_id."'";
$result_queue = mysql_query($query_queue) or die("SELECT QUEUE ".mysql_error());
$row_queue = mysql_fetch_array($result_queue);

$query_driver = "SELECT fname,lname,mname FROM employee_tbl WHERE autoid='".$row_queue['driver_id']."'";
$result_driver = mysql_query($query_driver) or die("SELECT DRIVER ".mysql_error());
$row_driver = mysql_fetch_array($result_driver);
$helpers_id = $row_queue['helpers_id'];
?>
<html>
<head>
<style type='text/css'>
.under
{
 text-decoration:underline;
}
</style>
<script type="text/javascript">
function print_doc()
{
window.print();
}
</script>
</head>
<body onLoad='print_doc()'>
<table border='0' width='810'>
<tr>
	<td width='32%' align='center' colspan='6' style='font-weight:bold;text-decoration:underline;'>QUEUE SLIP</td>
</tr>
<tr>
	<td width='16%' style='font-weight:bold'>DR NO:</td>
	<td width='18%'><?php echo $row_queue['dr_no'];?></td>
	<td width='32%' align='center' colspan='2' style='font-weight:bold;text-decoration:underline;'></td>
	<td width='15%' style='font-weight:bold'>QUEUE NO.</td>
	<td width='19%'><?php echo $row_queue['queue_no'];?></td>
</tr>
<tr>
	<td style='font-weight:bold'>SEQUENCE NO:</td>
	<td colspan='3' ><?php echo $row_queue['sequence_no'];?></td>
  <td style='font-weight:bold'>S.O. NO.</td>
	<td><?php echo $row_queue['so_no'];?></td>
</tr>
<tr>
	<td style='font-weight:bold'>PLATE NO</td>
	<td><?php echo $row_queue['plate_no'];?></td>
	<td width='14%'style='font-weight:bold'>TRIP NO</td>
	<td width='18%'><?php echo $row_queue['trip_no'];?></td>
</tr>
<tr>
	<td style='font-weight:bold' >DRIVER NAME</td>
	<td><?php echo $row_driver['lname'];?></td>
  <td><?php echo $row_driver['fname'];?></td>
  <td><?php echo $row_driver['mname'];?></td>
</tr>
<tr>
	<td style='font-weight:bold'>HAULER</td>
	<td><?php echo $row_queue['hauler_name'];?></td>
	<td width='14% 'style='font-weight:bold'>TRUCK TYPE</td>
	<td width='18%'><?php echo $row_queue['truck_type'];?></td>
	<td style='font-weight:bold'>HAULER TYPE</td>
	<td><?php echo $row_queue['hauler_type'];?></td>
</tr>
</table>

<br />
<br />
<table border='0' width='810'>
<tr>
	<td width='25%' style='font-weight:bold'>ARRIVAL AT PLANT</td>
	<td width='25%'><?php echo $row_queue['arrival_at_plant']."&nbsp;&nbsp;&nbsp;".$row_queue['arrival_at_plant_time'];?></td>
	<td width='50%' colspan='2' style='font-weight:bold;text-decoration:underline;'>CUSTOMER INFORMATION</td>
</tr>
<tr>
	<td width='25%' style='font-weight:bold'>LOAD CONFIRMED</td>
	<td width='25%'><?php echo $row_queue['load_confirmed']."&nbsp;&nbsp;&nbsp;".$row_queue['load_confirmed_time'];?></td>
	<td width='25%' style='font-weight:bold'>CUSTOMER NUMBER</td>
	<td width='25%'><?php echo $row_queue['cust_no'];?></td>
</tr>
<tr>
	<td style='font-weight:bold'>DEPARTURE ON PLANT</td>
	<td><?php echo $row_queue['dept_on_plant']."&nbsp;&nbsp;&nbsp;".$row_queue['dept_on_plant_time'];?></td>
	<td style='font-weight:bold'>CUSTOMER NAME</td>
	<td><?php echo $row_queue['cust_name'];?></td>
</tr>
<tr>
	<td style='font-weight:bold'>ESTIMATED RETURN</td>
	<td><?php echo $row_queue['est_return']."&nbsp;&nbsp;&nbsp;".$row_queue['est_return_time'];?></td>
	<td style='font-weight:bold'>LOCATION/ZONE</td>
	<td><?php echo $row_queue['cust_loc'];?></td>
</tr>
</table>


<br />
<br />
<table border='0' width='810'>
<tr>
	<td width='25%' style='font-weight:bold'>ARRIVAL AT CLIENT</td>
	<td width='25%'><?php echo $row_queue['arrival_at_client']."&nbsp;&nbsp;&nbsp;".$row_queue['arrival_at_client_time'];?></td>
	<td width='25%' style='font-weight:bold'>DELIVERY CONFIRMED</td>
	<td width='25%' align='center'>____________________</td>
</tr>
<tr>
	<td style='font-weight:bold'>ACTUAL UNLOADING</td>
	<td><?php echo $row_queue['actual_unloading']."&nbsp;&nbsp;&nbsp;".$row_queue['actual_unloading_time'];?></td>
	<td>&nbsp;</td>
	<td style='font-weight:bold;font-size:10px;' align='center'>CUSTOMER'S SIGNATURE</td>
</tr>
<tr>
	<td style='font-weight:bold'>DEPARTURE AT CLIENT</td>
	<td><?php echo $row_queue['departure_at_client']."&nbsp;&nbsp;&nbsp;".$row_queue['departure_at_client_time'];?></td>
	<td style='font-weight:bold'>DRIVER'S SIGNATURE</td>
	<td align='center'>____________________</td>
</tr>
<tr>
	<td style='font-weight:bold'>RETURN TO PLANT</td>
	<td><?php echo $row_queue['return_to_plant']."&nbsp;&nbsp;&nbsp;".$row_queue['return_to_plant_time'];?></td>
</tr>
<tr>
	<td style='font-weight:bold'>REMARKS</td>
	<td align='center'>____________________</td>
</tr>
</table>

<br />
<br />
<span style='font-weight:bold'>LIST OF HELPERS</span><br />
<?php
$arr_ids = explode(',',$helpers_id);
foreach($arr_ids as $hid)
{
 $sel_helper = "SELECT fname, lname FROM employee_tbl WHERE autoid='".$hid."'";
 $res_helper = mysql_query($sel_helper) or die("SELECT HELPERS ".mysql_error());
 $row_helper = mysql_fetch_array($res_helper);
 echo $row_helper['lname'].", ".$row_helper['fname']."<br />";
}
?>
<br />
<br />
<p style='font-weight:bold;text-align:center;'>***************NOTHING FOLLOWS***************</p>

<br />
<br />
<table border='0' width='810'>
<tr>
	<td width='23%' style='font-weight:bold'>PILER'S NAME</td>
	<td width='55%'>&nbsp;</td>
	<td width='22%'>&nbsp;</td>
</tr>
<tr>
	<td>1.____________________</td>
	<td style='font-weight:bold'>TC COORDINATIOR ON DUTY(DEPARTURE AT PLANT)</td>
	<td>_______________________</td>
</tr>
<tr>
	<td>2.____________________</td>
	<td style='font-weight:bold'>TC COORDINATIOR ON DUTY(RETURN AT PLANT)</td>
	<td>_______________________</td>
</tr>
<tr>
	<td>3.____________________</td>
</tr>
<tr>
	<td style='font-weight:bold'>CUSTOMER REMARKS:</td>
</tr>
</table>
<br/>
<br/>
<br/>
<br/>
</body>
</html>